#!/bin/bash

# traz as copias dos confs
# Matheus - 12/12/2014
# Matheus - 08/01/2015 - copiar arquivos de conf de rede
# Matheus - 06/03/2015 - copiar arquivos do rt natal

. consulta_versao_scripts.conf

CONFS=natal/confs
SYSCONFS=natal/sysconfs

  echo "==> Configuracao do Script de rotas"

# comecando do 1, para pular o rt-natal !
for i in `seq 1 $COUNT`
do
  echo -n "===> ${VT[$i]}"
  echo -ne '   \t'
  # Sempre o mesmo roteador, mudando o dir da VT
  (scp root@${ROTEADOR[0]}:rotas/${VT[$i]}/script_rotas.conf $CONFS/script_rotas.conf.${VT[$i]} >/dev/null 2>&1) && echo OK
done

  echo -n "===> Configuracoes de rede"
  echo -ne '   \t'
  for arq in /etc/sysconfig/network /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth1 \
		/etc/sysconfig/network-scripts/ifcfg-eth2 /etc/sysconfig/network-scripts/route-eth0 \
		/etc/sysconfig/network-scripts/route-eth1 /etc/sysconfig/network-scripts/route-eth2
  do
    mkdir -p $SYSCONFS/network/${VT[$i]} > /dev/null 2>&1
    (scp root@${ROTEADOR[0]}:$arq $SYSCONFS/network/ >/dev/null 2>&1) && echo -n "OK "
  done

  echo
  echo

  echo -n "===> Configuracoes da pasta /root"
  echo -ne '   \t'
  for arq in /etc/rc.local /root/rotas_vts.sh
  do
    mkdir -p $SYSCONFS/root > /dev/null 2>&1
    (scp root@${ROTEADOR[0]}:$arq $SYSCONFS/root/ >/dev/null 2>&1) && echo -n "OK "
  done

  echo
